import socket

sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.connect(('localhost',8888))
while True:
    msg = input("请输入消息（输入exit退出）：")
    if msg == 'exit':
        break
    sock.sendall(msg.encode())
    data = sock.recv(1024)
    print(f"收到回应：{data.decode()}")

sock.close()
print("连接关闭！")